package com.lightdz.tshirtdz.dal.impl;

import com.lightdz.tshirtdz.model.entity.OrderRecordEntity;

import com.lightdz.tshirtdz.utils.MybatisDBHelper;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @ Description：${description}
 * @ Author     ：zbl
 * @ Date       ：Created in 16:54 09/08/2018
 * @ Modified By：
 */

@Repository
public class OrderDal {

    /**
     * 获取我的订单
     *
     * @param wxId
     * @return
     */
    public List<OrderRecordEntity> getOrderList(String wxId) {

        List<OrderRecordEntity> orderList =(List<OrderRecordEntity>) MybatisDBHelper.SelectListById("getOrderList",wxId);
        return orderList;
    }

    /**
     * 添加到我的订单
     *
     * @return
     */
    public boolean addOrderRecord(OrderRecordEntity entity) {

        int result = MybatisDBHelper.Add("addOrderRecord", entity);
        return result > 0;
    }

    /**
     * 我的订单
     * @param wxId
     * @param orderId
     * @return
     */
    public boolean deleteOrderRecord(String wxId, long orderId) {
        OrderRecordEntity entity = new OrderRecordEntity();
        entity.setWxid(wxId);
        entity.setTid((int) orderId);
        int result = MybatisDBHelper.Delete("deleteOrderRecord", entity);
        return result > 0;
    }
}
